package network;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 10 - 06
 * Time: 16:34
 */
public class TcpDictServer extends TcpEchoServer{
    private Map<String, String> dict = new HashMap<>();
    public TcpDictServer(int port) throws IOException {
        super(port);
        dict.put("cat", "小猫");
        dict.put("fish", "小鱼");
        dict.put("dog", "小狗");
    }
    @Override
    public String process(String request) {
        return dict.getOrDefault(request, "该词在词典中不存在该词!");
    }

    public static void main(String[] args) throws IOException {
        TcpDictServer tcpDictServer = new TcpDictServer(9090);
        tcpDictServer.start();
    }
}
